package com.wei.czz.common.enums.admin.deptUser;

import com.wei.czz.common.dto.common.NameValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wei
 * date: 2022-09-22 21:04:03
 * className: UserDeptMoveModeEnum 用户关联部门切换模式枚举类
 * version: 1.0
 * description:
 */
@Getter
@AllArgsConstructor
public enum DeptUserMoveModeEnum {

    SAVE(-1, "新用户"),

    ONE(0, "单个用户"),

    BATCH(1, "批量切换"),

    ALL(2, "全部切换"),

    JOIN(3, "加入")
    ;

    /**
     * 字典值
     */
    private final Integer value;

    /**
     * 字典值的描述信息
     */
    private final String name;

    /**
     * 获取名称
     * @param value 值
     * @return 名称
     */
    public static String getName(Integer value) {
        if (Objects.isNull(value)) {
            return "";
        }
        for (DeptUserMoveModeEnum deptUserMoveModeEnum : values()) {
            if (deptUserMoveModeEnum.value.equals(value)) {
                return deptUserMoveModeEnum.name;
            }
        }
        return "";
    }

    /**
     * 获取枚举列表
     */
    public static List<NameValue<Integer>> getList() {
        return Stream.of(values())
                .map(deptUserMoveModeEnum -> new NameValue<>(deptUserMoveModeEnum.name, deptUserMoveModeEnum.value))
                .collect(Collectors.toList());
    }

}
